home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / camo.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  3.6 KB  |  112 lines

  1. ;
  2. ;
  3. ;
  4. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  5. ; At ECS Dept, University of Southampton, England.
  6.  
  7. ; This program is free software: you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 3 of the License, or
  10. ; (at your option) any later version.
  11. ;
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ; GNU General Public License for more details.
  16. ;
  17. ; You should have received a copy of the GNU General Public License
  18. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  
  20.  
  21. (define (script-fu-camo-pattern inSize inGrain inColor1 inColor2 inColor3 inSmooth inFlatten)
  22.  
  23.   (let* (
  24.         (theWidth inSize)
  25.         (theHeight inSize)
  26.         (theImage (car (gimp-image-new theWidth theHeight RGB)))
  27.         (baseLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE "Background" 100 NORMAL-MODE)))
  28.         (thickLayer 0)
  29.         (thinLayer 0)
  30.         (theBlur 0)
  31.         )
  32.  
  33.     (gimp-context-push)
  34.  
  35.     (gimp-image-add-layer theImage baseLayer 0)
  36.  
  37.     (set! thickLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE "Camo Thick Layer" 100 NORMAL-MODE)))
  38.     (gimp-image-add-layer theImage thickLayer 0)
  39.  
  40.     (set! thinLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE "Camo Thin Layer" 100 NORMAL-MODE)))
  41.     (gimp-image-add-layer theImage thinLayer 0)
  42.  
  43.     (gimp-selection-all theImage)
  44.     (gimp-context-set-background inColor1)
  45.     (gimp-drawable-fill baseLayer BACKGROUND-FILL)
  46.  
  47.     (plug-in-solid-noise RUN-NONINTERACTIVE
  48.              theImage thickLayer 1 0 (rand 65536) 1 inGrain inGrain)
  49.     (plug-in-solid-noise RUN-NONINTERACTIVE
  50.              theImage thinLayer 1 0 (rand 65536) 1 inGrain inGrain)
  51.     (gimp-threshold thickLayer 127 255)
  52.     (gimp-threshold thinLayer 145 255)
  53.  
  54.     (set! theBlur (- 16 inGrain))
  55.  
  56.     (gimp-context-set-background inColor2)
  57.     (gimp-by-color-select thickLayer
  58.               '(0 0 0) 127 CHANNEL-OP-REPLACE TRUE FALSE 0 FALSE)
  59.     (gimp-edit-clear thickLayer)
  60.     (gimp-selection-invert theImage)
  61.     (gimp-edit-fill thickLayer BACKGROUND-FILL)
  62.     (gimp-selection-none theImage)
  63.     (if (= inSmooth TRUE)
  64.         (script-fu-tile-blur theImage thickLayer theBlur TRUE TRUE FALSE)
  65.     )
  66.  
  67.  
  68.     (gimp-context-set-background inColor3)
  69.     (gimp-by-color-select thinLayer '(0 0 0) 127 CHANNEL-OP-REPLACE  TRUE FALSE 0 FALSE)
  70.     (gimp-edit-clear thinLayer)
  71.     (gimp-selection-invert theImage)
  72.     (gimp-edit-fill thinLayer BACKGROUND-FILL)
  73.     (gimp-selection-none theImage)
  74.     (if (= inSmooth TRUE)
  75.         (script-fu-tile-blur theImage thinLayer (/ theBlur 2) TRUE TRUE FALSE)
  76.     )
  77.  
  78.  
  79.     (if (= inFlatten TRUE)
  80.         (gimp-image-flatten theImage)
  81.     )
  82.  
  83.     (gimp-display-new theImage)
  84.  
  85.     (gimp-context-pop)
  86.   )
  87. )
  88.  
  89.  
  90. ; Register the function with GIMP:
  91.  
  92. (script-fu-register
  93.   "script-fu-camo-pattern"
  94.   _"_Camouflage..."
  95.   _"Create an image filled with a camouflage pattern"
  96.   "Chris Gutteridge: cjg@ecs.soton.ac.uk"
  97.   "28th April 1998"
  98.   "Chris Gutteridge / ECS @ University of Southampton, England"
  99.   ""
  100.   SF-ADJUSTMENT _"Image size"    '(256 10 1000 1 10 0 1)
  101.   SF-ADJUSTMENT _"Granularity"   '(7 0 15 1 1 0 0)
  102.   SF-COLOR      _"Color 1"       '(33 100 58)
  103.   SF-COLOR      _"Color 2"       '(170 170 60)
  104.   SF-COLOR      _"Color 3"       '(150 115 100)
  105.   SF-TOGGLE     _"Smooth"        FALSE
  106.   SF-TOGGLE     _"Flatten image" TRUE
  107. )
  108.  
  109.  
  110. (script-fu-menu-register "script-fu-camo-pattern"
  111.                          "<Image>/File/Create/Patterns")
  112.